home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / as03.arc / NEWNAME.ASM next >
Assembly Source File  |  1984-10-10  |  3KB  |  92 lines

  1. ;     written 10/3/84 gwf
  2. ;NEWNAME --- This program will rename (and even change directories)
  3. ; of a given file. The drive, path, and name of the file to be
  4. ; renamed is the first parameter sent. The new path and name is the
  5. ; second parameter sent.
  6.  
  7. ;
  8. ; DEFINTION --- An absolute file name is the drive designator
  9. ;   followed by the complete path from the root to the actual
  10. ;   file name. E.g. PED3.EXE lives in the \SYS\PL directory on
  11. ;   on the C drive. Its absolute file name is:
  12. ;         C:\SYS\PL\PED3.EXE
  13. ;
  14. ;
  15. ;     ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈
  16. ;       CALL NEWNAME(OLD.NAME,NEW.NAME)     
  17. ; Call with parameters present absolute name +CHR$(0) as first
  18. ;  parameter, desired absolute name +CHR$(0) as second parameter.
  19. ;  The drive designator on the second parameter can be omitted
  20. ;  if the drive designator on the first parameter is the default
  21. ;  drive. Otherwise, both drive designators must be present.
  22. ;     ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈
  23. ;
  24. ;              Example program to compile
  25. ;
  26. ;          10 color 7,1:cls
  27. ;          20 input"Present location & name ",ans$
  28. ;          30 X$=ans$+CHR$(0)
  29. ;          40 input"Desired location & name ",ans$
  30. ;          50 Y$=ans$+CHR$(0)'
  31. ;          60 print"Just before call ";time$
  32. ;          70 CALL NEWNAME(X$,Y$)
  33. ;          80 print"Just after call ";time$
  34. ;
  35. ;
  36. re_name equ    56h    ;Rename a file function call
  37. doscall equ    21h    ;DOS interrupt number
  38.  
  39.  
  40.  
  41. ;Names must have a byte zero to indicate their termination
  42. ;                called ASCIIZ
  43.  
  44.  
  45. ;The manual says the preceeding drive indicator is not necessary
  46. ;  on the new name. I cannot get it to work without it,
  47. ;  Unless the drive to be used is the default drive.
  48. ;  For best results use the drive!
  49.  
  50. ;*****************************************************************************
  51.  
  52.  
  53. cseg    segment  'CODE'         ;define code segment
  54. ;---------------------------------------------------------------------
  55.  
  56.    assume cs:cseg
  57.    public newname
  58. newname proc far    ;main part of program
  59.  
  60.  
  61.  
  62. ;set up stack for return
  63.     push bp     ;save for return
  64.     mov  bp,sp    ;set base for passed names
  65.     push ds     ;save old data segment
  66.     push es     ;save for return
  67.  
  68.  
  69. ;MAIN PART OF PROGRAM.
  70. ;DX points to old name
  71.  
  72.     mov  si,[bp+8]         ;get address of second parameter
  73.     mov  ax,[si+2]         ;get actual address of string
  74.     mov  dx,ax         ;location of old name put in DX
  75. ;DI points to new name
  76.     mov  si,[bp+6]         ;get address of first parameter
  77.     mov  ax,[si+2]         ;get actual address of string
  78.     mov  di,ax         ;location of new name put in DI
  79.     mov  ah,re_name      ;rename function number
  80.     int  doscall         ;Call DOS
  81.  
  82.     pop  es
  83.     pop  ds
  84.     pop  bp
  85.     ret  4            ;return to calling program
  86.                 ;   (4 since 2 parameters passed)
  87. newname endp            ;end of main part of program
  88. ;---------------------------------------------------------------------
  89. cseg    ends        ;end of code segment
  90. ;*********************************************************************
  91.     end        ;end of assembly
  92.